clear
eststo clear
use "Camps replication data.dta"

***FIGURE 2***
eststo clear
reg rationcard treatment, cluster(village)
estimates store rationcard
reg trust_state treatment, cluster(village)
estimates store trust_state
reg trustpradhan treatment, cluster(village)
estimates store trustpradhan
reg trustutility treatment, cluster(village)
estimates store trustutility
reg trustneighbors treatment, cluster(village)
estimates store trustneighbors
reg econ1 treatment, cluster(village)
estimates store econ1
reg econ2 treatment, cluster(village)
estimates store econ2
reg econ3 treatment, cluster(village)
estimates store econ3
reg heard treatment, cluster(village)
estimates store heard
reg highcost treatment, cluster(village)
estimates store highcost
reg poorservice treatment, cluster(village)
estimates store poorservice
reg lackcash treatment, cluster(village)
estimates store lackcash
reg donotneed treatment, cluster(village)
estimates store donotneed
reg knowhowapply treatment, cluster(village)
estimates store knowhowapply
reg connectioncost treatment, cluster(village)
estimates store connectioncost
reg connectioncost_dk treatment, cluster(village)
estimates store connectioncost_dk

coefplot (heard, ciopts(lcolor(blue) mcolor(black))) (connectioncost, ciopts(lcolor(blue) mcolor(black))) (connectioncost_dk, ciopts(lcolor(blue) mcolor(black))) (knowhowapply, ciopts(lcolor(blue) mcolor(black))) (rationcard, ciopts(lcolor(red) mcolor(black))) (econ1, ciopts(lcolor(red) mcolor(black))) (econ2, ciopts(lcolor(red) mcolor(black))) (econ3, ciopts(lcolor(red) mcolor(black))) (donotneed, ciopts(lcolor(blue) mcolor(black))) (poorservice, ciopts(lcolor(blue) mcolor(black))) (highcost, ciopts(lcolor(blue) mcolor(black))) (lackcash, ciopts(lcolor(blue) mcolor(black))) (trustutility, ciopts(lcolor(red) mcolor(black))) (trust_state, ciopts(lcolor(red) mcolor(black))) (trustneighbors, ciopts(lcolor(red) mcolor(black))) (trustpradhan, ciopts(lcolor(red) mcolor(black))), mlcolor(black) mfcolor(white) xtick(-.3(.3).3) xlabel(-.3(.3).3) xscale(range(-.3 .3))  graphregion(fcolor(white))    drop(_cons) xline(0) legend(off) aseq swapnames graphregion(margin(l+40 r+10))  mlabsize(tiny)
eststo clear

***FIGURE 3***
reg applied i.treatment i.feeder, cluster(village)
margins treatment_dum, atmeans predict(xb) post coeflegend
gen apply_control_bi = _b[0bn.treatment_dum]
gen apply_treatment_bi = _b[1.treatment_dum]

matrix rV = r(V)
gen apply_control_bi_se = sqrt(rV[1,1])
gen apply_treat_bi_se = sqrt(rV[2,2])


reg received i.treatment i.feeder, cluster(village)
margins treatment_dum, atmeans predict(xb) post coeflegend
gen receive_control_bi = _b[0bn.treatment_dum]
gen receive_treatment_bi = _b[1.treatment_dum]

matrix rV = r(V)
gen receive_control_bi_se = sqrt(rV[1,1])
gen receive_treat_bi_se = sqrt(rV[2,2])


reg perceivedifficulty i.treatment i.feeder, cluster(village)
margins treatment_dum, atmeans predict(xb) post coeflegend
gen difficulty_control_bi = _b[0bn.treatment_dum]
gen difficulty_treatment_bi = _b[1.treatment_dum]

matrix rV = r(V)
gen difficulty_control_bi_se = sqrt(rV[1,1])
gen difficulty_treat_bi_se = sqrt(rV[2,2])

reg perceivecost i.treatment i.feeder, cluster(village)
margins treatment_dum, atmeans predict(xb) post coeflegend
gen  cost_control_bi = _b[0bn.treatment_dum]
gen cost_treatment_bi = _b[1.treatment_dum]

matrix rV = r(V)
gen cost_control_bi_se = sqrt(rV[1,1])
gen cost_treat_bi_se = sqrt(rV[2,2])




reg applied i.treatment i.feeder rationcard econ2 econ3, cluster(village)
margins treatment_dum, atmeans predict(xb) post coeflegend
gen apply_control_multi = _b[0bn.treatment_dum]
gen apply_treatment_multi = _b[1.treatment_dum]

matrix rV = r(V)
gen apply_control_multi_se = sqrt(rV[1,1])
gen apply_treat_multi_se = sqrt(rV[2,2])


reg received i.treatment i.feeder rationcard econ2 econ3, cluster(village)
margins treatment_dum, atmeans predict(xb) post coeflegend
gen receive_control_multi = _b[0bn.treatment_dum]
gen receive_treatment_multi = _b[1.treatment_dum]

matrix rV = r(V)
gen receive_control_multi_se = sqrt(rV[1,1])
gen receive_treat_multi_se = sqrt(rV[2,2])


reg perceivedifficulty i.treatment i.feeder rationcard econ2 econ3, cluster(village)
margins treatment_dum, atmeans predict(xb) post coeflegend
gen difficulty_control_multi = _b[0bn.treatment_dum]
gen difficulty_treatment_multi = _b[1.treatment_dum]

matrix rV = r(V)
gen difficulty_control_multi_se = sqrt(rV[1,1])
gen difficulty_treat_multi_se = sqrt(rV[2,2])

reg perceivecost i.treatment i.feeder rationcard econ2 econ3, cluster(village)
margins treatment_dum, atmeans predict(xb) post coeflegend
gen  cost_control_multi = _b[0bn.treatment_dum]
gen cost_treatment_multi = _b[1.treatment_dum]

matrix rV = r(V)
gen cost_control_multi_se = sqrt(rV[1,1])
gen cost_treat_multi_se = sqrt(rV[2,2])


preserve
drop if _n > 5
gen order = _n
gen coef = apply_control_bi if order==1
replace coef = apply_treatment_bi if order==2
replace coef = apply_control_multi if order==4
replace coef = apply_treatment_multi if order==5
gen cihigh = coef+(1.96*apply_control_bi_se) if order==1
gen cilow = coef-(1.96*apply_control_bi_se) if order==1
replace cihigh = coef+(1.96*apply_treat_bi_se) if order==2
replace cilow = coef-(1.96*apply_treat_bi_se) if order==2
replace cihigh = coef+(1.96*apply_control_multi_se) if order==4
replace cilow = coef-(1.96*apply_control_multi_se) if order==4
replace cihigh = coef+(1.96*apply_treat_multi_se) if order==5
replace cilow = coef-(1.96*apply_treat_multi_se) if order==5
replace coef = coef*100
replace cihigh = cihigh*100
replace cilow = cilow*100
twoway (bar coef order if order==1 | order==4) ///
||  (bar coef order if order==2 | order==5) ///
|| (rcap cihigh cilow order, mcolor(blue) lcolor(black) lwidth(medthick) msize(large)), ytitle(% of Households Applying) xtitle("") xlabel(1.5 "Baseline***" 4.5 "With Controls***") graphregion(fcolor(white)) legend(order(1 "Control (N=996)" 2 "Treatment (N=996)" 3 "95% CI"))
eststo clear

restore



preserve
drop if _n > 5
gen order = _n
gen coef = receive_control_bi if order==1
replace coef = receive_treatment_bi if order==2
replace coef = receive_control_multi if order==4
replace coef = receive_treatment_multi if order==5
gen cihigh = coef+(1.96*receive_control_bi_se) if order==1
gen cilow = coef-(1.96*receive_control_bi_se) if order==1
replace cihigh = coef+(1.96*receive_treat_bi_se) if order==2
replace cilow = coef-(1.96*receive_treat_bi_se) if order==2
replace cihigh = coef+(1.96*receive_control_multi_se) if order==4
replace cilow = coef-(1.96*receive_control_multi_se) if order==4
replace cihigh = coef+(1.96*receive_treat_multi_se) if order==5
replace cilow = coef-(1.96*receive_treat_multi_se) if order==5
replace coef = coef*100
replace cihigh = cihigh*100
replace cilow = cilow*100
twoway (bar coef order if order==1 | order==4) ///
||  (bar coef order if order==2 | order==5) ///
|| (rcap cihigh cilow order, lcolor(black) lwidth(medthick) msize(large)), ytitle(% of Households Receiving) xtitle("") xlabel(1.5 "Baseline" 4.5 "With Controls") graphregion(fcolor(white)) legend(order(1 "Control (N=996)" 2 "Treatment (N=996)" 3 "95% CI"))
eststo clear
restore

preserve
drop if _n > 5
gen order = _n
gen coef = difficulty_control_bi if order==1
replace coef = difficulty_treatment_bi if order==2
replace coef = difficulty_control_multi if order==4
replace coef = difficulty_treatment_multi if order==5
gen cihigh = coef+(1.96*difficulty_control_bi_se) if order==1
gen cilow = coef-(1.96*difficulty_control_bi_se) if order==1
replace cihigh = coef+(1.96*difficulty_treat_bi_se) if order==2
replace cilow = coef-(1.96*difficulty_treat_bi_se) if order==2
replace cihigh = coef+(1.96*difficulty_control_multi_se) if order==4
replace cilow = coef-(1.96*difficulty_control_multi_se) if order==4
replace cihigh = coef+(1.96*difficulty_treat_multi_se) if order==5
replace cilow = coef-(1.96*difficulty_treat_multi_se) if order==5
twoway (bar coef order if order==1 | order==4) ///
||  (bar coef order if order==2 | order==5) ///
|| (rcap cihigh cilow order, lcolor(black) lwidth(medthick) msize(large)), ytitle(Perceived Ease of Applying) ytick(0(1)5) ylabel(0(1)5) yscale(range(0 5) titlegap(1)) xtitle("") xlabel(1.5 "Baseline***" 4.5 "With Controls***") graphregion(fcolor(white)) legend(order(1 "Control (N=719)" 2 "Treatment (N=702)" 3 "95% CI"))
eststo clear
restore

preserve
drop if _n > 5
gen order = _n
gen coef = cost_control_bi if order==1
replace coef = cost_treatment_bi if order==2
replace coef = cost_control_multi if order==4
replace coef = cost_treatment_multi if order==5
gen cihigh = coef+(1.96*cost_control_bi_se) if order==1
gen cilow = coef-(1.96*cost_control_bi_se) if order==1
replace cihigh = coef+(1.96*cost_treat_bi_se) if order==2
replace cilow = coef-(1.96*cost_treat_bi_se) if order==2
replace cihigh = coef+(1.96*cost_control_multi_se) if order==4
replace cilow = coef-(1.96*cost_control_multi_se) if order==4
replace cihigh = coef+(1.96*cost_treat_multi_se) if order==5
replace cilow = coef-(1.96*cost_treat_multi_se) if order==5
twoway (bar coef order if order==1 | order==4) ///
||  (bar coef order if order==2 | order==5) ///
|| (rcap cihigh cilow order, lcolor(black) lwidth(medthick) msize(large)), ytitle(Perceived Affordability of Applying) ytick(0(1)5) ylabel(0(1)5) yscale(range(0 5) titlegap(1)) xtitle("") xlabel(1.5 "Baseline***" 4.5 "With Controls***") graphregion(fcolor(white)) legend(order(1 "Control (N=709)" 2 "Treatment (N=663)" 3 "95% CI"))
eststo clear
restore

***FIGURE 4***
reg submit_2wks tcratesatisfaction tcratedifficulty tcratecost tcfeellearned tcquestionsanswered econ2 econ3 i.feeder if treatment==1, cluster(village)
estimates store causal
coefplot causal, keep(tcratesatisfaction tcratedifficulty tcratecost tcfeellearned tcquestionsanswered) xlabel(, format(%03.1f)) mfcolor(white) graphregion(fcolor(white)) xtitle("Predicted impact on decision to apply")  xline(0) legend(off) mlabsize(vsmall)
eststo clear


***TABLE A2***
sutex treatment applied received perceivedifficulty perceivecost trust heard rationcard econ1 econ2 econ3 trust_state trustutility trustpradhan trustneighbors highcost poorservice lackcash donotneed knowhowapply connectioncost connectioncost_dk, labels minmax


***TABLE A3***
reg applied trustpradhan trustneighbors i.feeder, cluster(village)
reg received trustpradhan trustneighbors i.feeder, cluster(village)
reg perceivedifficulty trustpradhan trustneighbors i.feeder, cluster(village)
reg perceivecost trustpradhan trustneighbors i.feeder, cluster(village)
eststo clear


***TABLE A4***
reg applied treatment trustneighbors trustpradhan i.feeder, cluster(village)
reg received treatment trustneighbors trustpradhan i.feeder, cluster(village)
reg perceivedifficulty treatment trustneighbors trustpradhan i.feeder, cluster(village)
reg perceivecost treatment trustneighbors trustpradhan i.feeder, cluster(village)
eststo clear


***TABLE A5***
reg applied treatment i.feeder, cluster(village)
reg received treatment i.feeder, cluster(village)
reg perceivedifficulty treatment i.feeder, cluster(village)
reg perceivecost treatment i.feeder, cluster(village)
eststo clear



***TABLE A6***
logit applied treatment i.feeder, cluster(village)
logit received treatment i.feeder, cluster(village)
ologit perceivedifficulty treatment i.feeder, cluster(village)
ologit perceivecost treatment i.feeder, cluster(village)
eststo clear




***TABLE A7***
reg applied i.feeder treatment rationcard econ2 econ3, cluster(village)
reg received i.feeder treatment rationcard econ2 econ3, cluster(village)
reg perceivedifficulty i.feeder treatment rationcard econ2 econ3, cluster(village)
reg perceivecost i.feeder treatment rationcard econ2 econ3, cluster(village)
eststo clear




***TABLE A8***
egen enum = group(enumerator)
reg applied treatment i.feeder i.enum, cluster(village)
reg received treatment i.feeder i.enum, cluster(village)
reg perceivedifficulty treatment i.feeder i.enum, cluster(village)
reg perceivecost treatment i.feeder i.enum, cluster(village)
eststo clear


***TABLE A11*** (Note: Requires leebounds package)
leebounds perceivedifficulty treatment, cie
leebounds perceivecost treatment, cie
eststo clear


***TABLE A13***
reg applied i.feeder treatment econ2 econ3, cluster(village)
reg received i.feeder treatment econ2 econ3, cluster(village)
reg perceivedifficulty i.feeder treatment econ2 econ3, cluster(village)
reg perceivecost i.feeder treatment econ2 econ3, cluster(village)
eststo clear




***TABLE A14***
reg submit_2wks tcratesatisfaction tcratedifficulty tcratecost tcfeellearned tcquestions econ2 econ3 i.feeder if treatment==1, cluster(village)
eststo clear




***TABLE A15***
reg applied treatment rationcard econ2 econ3 trust trust_treatment i.feeder, cluster(village)
reg received treatment rationcard econ2 econ3 trust trust_treatment i.feeder, cluster(village)
reg perceivedifficulty treatment rationcard econ2 econ3 trust trust_treatment i.feeder, cluster(village)
reg perceivecost treatment rationcard econ2 econ3 trust trust_treatment i.feeder, cluster(village)
eststo clear



***TABLE A16***
gen trust2 = 0 if trust != .
gen trust3 = 0 if trust != .
gen trust4 = 0 if trust != .
gen trust5 = 0 if trust != .
replace trust2 = 1 if trust < 4 & trust != .
replace trust3 = 1 if trust==4 | trust==4.25
replace trust4 = 1 if trust==4.5
replace trust5 = 1 if trust==5  | trust==4.75

gen trust_dum = 0
replace trust_dum = 1 if trust> 4.4 & trust != .

gen trust2_treatment = trust2 * treatment
gen trust3_treatment = trust3 * treatment
gen trust4_treatment = trust4 * treatment
gen trust5_treatment = trust5 * treatment

label var trust2 "Low trust"
label var trust3 "Medium trust"
label var trust4 "High trust"
label var trust5 "Very high trust"

label var trust2_treatment "Low trust * Campaign"
label var trust3_treatment "Medium trust * Campaign"
label var trust4_treatment "High trust * Campaign"
label var trust5_treatment "Very high trust * Campaign"


reg applied treatment rationcard econ2 econ3 trust3 trust4 trust5 trust3_treatment trust4_treatment trust5_treatment i.feeder, cluster(village)
reg received treatment rationcard econ2 econ3 trust3 trust4 trust5 trust3_treatment trust4_treatment trust5_treatment i.feeder, cluster(village)
reg perceivedifficulty treatment rationcard econ2 econ3 trust3 trust4 trust5 trust3_treatment trust4_treatment trust5_treatment i.feeder, cluster(village)
reg perceivecost treatment rationcard econ2 econ3 trust3 trust4 trust5 trust3_treatment trust4_treatment trust5_treatment i.feeder, cluster(village)
eststo clear




***FIGURE A1***
reg applied treatment rationcard econ2 econ3 trust trust_treatment i.feeder, cluster(village)
estimates store applied
reg received treatment rationcard econ2 econ3 trust trust_treatment i.feeder, cluster(village)
estimates store received
reg perceivedifficulty treatment rationcard econ2 econ3 trust trust_treatment i.feeder, cluster(village)
estimates store perceivedifficulty
reg perceivecost treatment rationcard econ2 econ3 trust trust_treatment i.feeder, cluster(village)
estimates store perceivecost
coefplot (applied, ciopts(lcolor(blue) mcolor(black))) (received, ciopts(lcolor(red) mcolor(black))) (perceivedifficulty, ciopts(lcolor(blue) mcolor(black))) (perceivecost, ciopts(lcolor(red) mcolor(black))), mlcolor(black) mfcolor(white) graphregion(fcolor(white)) xlabel(, format(%03.1f))  keep(treatment_dum trust trust_treatment) eqlabels("Campaign" "Trust" "Campaign * Trust") xline(0) legend(off) aseq swapnames mlabsize(vsmall)
eststo clear

***FIGURE A2*** (Note: Requires graph2tex package)
reg applied treatment rationcard econ2 econ3 trust c.treatment#c.trust i.feeder, cluster(village)
margins, dydx(treatment) at(trust=(1(1)5)) atmeans vsquish predict(xb)
marginsplot, graphregion(fcolor(white)) ylabel(, format(%03.1f)) yline(0) xtitle(Trust) ytitle(Effects on Applying for Connection) title(Conditional Effects of Campaign with 95% CI)
graph2tex, epsfile("Figures\Apply_mfx") caption(Effect of Campaign on Applying at levels of Trust)
reg received treatment rationcard econ2 econ3 trust c.treatment#c.trust i.feeder, cluster(village)
margins, dydx(treatment) at(trust=(1(1)5)) atmeans vsquish predict(xb)
marginsplot, graphregion(fcolor(white)) ylabel(, format(%03.1f)) yline(0) xtitle(Trust) ytitle(Effects on Receiving Connection) title(Conditional Effects of Campaign with 95% CI)
graph2tex, epsfile("Figures/Receive_mfx") caption(Effect of Campaign on Receiving at levels of Trust)
reg perceivedifficulty treatment rationcard econ2 econ3 trust c.treatment#c.trust i.feeder, cluster(village)
margins, dydx(treatment) at(trust=(1(1)5)) atmeans vsquish predict(xb)
marginsplot, graphregion(fcolor(white)) ylabel(, format(%03.1f)) yline(0) xtitle(Trust) ytitle(Effects on Perceived Ease) title(Conditional Effects of Campaign with 95% CI)
graph2tex, epsfile("Figures/Difficulty_mfx") caption(Effect of Campaign on Perceived Ease t levels of Trust)
reg perceivecost treatment rationcard econ2 econ3 trust c.treatment#c.trust i.feeder, cluster(village)
margins, dydx(treatment) at(trust=(1(1)5)) atmeans vsquish predict(xb)
marginsplot, graphregion(fcolor(white)) ylabel(, format(%03.1f)) yline(0) xtitle(Trust) ytitle(Effects on Perceived Affordability) title(Conditional Effects of Campaign with 95% CI)
graph2tex, epsfile("Figures/Cost_mfx") caption(Effect of Campaign on Receiving at levels of Trust)
eststo clear

***FIGURE A3***
reg applied treatment rationcard econ2 econ3 trust3 trust4 trust5 trust3_treatment trust4_treatment trust5_treatment i.feeder, cluster(village)
estimates store applied
coefplot applied, mfcolor(white) graphregion(fcolor(white))  keep(treatment_dum trust3 trust4 trust5 trust3_treatment trust4_treatment trust5_treatment) eqlabels("Campaign" "Trust" "Campaign * Trust") xtitle("Predicted impact on decision to apply") xlabel(, format(%03.1f)) xline(0) aseq mlabsize(vsmall)
eststo clear

